<?php

namespace App\Http\Requests\System;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class RoleCategory extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => [
                'required',
                Rule::unique('role_categories')
                    ->ignore(request()->id)
                    ->where(function ($query){
                        $query->whereNull('deleted_at');
                    }),
            ]
        ];
    }

    public function messages(){
        return [
            'name.required' => '请输入类型名称',
            'name.unique' => '类型名称重复'
        ];
    }
}
